package bounds.upper

object UpperBounds02 {
  def main(args: Array[String]): Unit = {
    biophony(Seq(new Bird, new Animal))
    biophony(Seq(new Animal, new Animal))
    biophony(Seq(new Animal, new Bird))
    //    biophony(Seq(new Earth, new Earth)) // 上界限定了类型
  }

  def biophony[T <: Animal](things: Seq[T]) = things map (_.sound())
}

class Earth {
  def sound(): Unit = {
    println("hello!")
  }

}

class Animal extends Earth {
  override def sound(): Unit = {
    println("animal sound")
  }
}

class Bird extends Animal {
  override def sound(): Unit = {
    println("bird sound")
  }
}